﻿#include "mainwindow.h"
#include "common_log.h"
#include "config_data.h"
#include "componentManager.h"
#include <QMessageBox>




MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	
}

MainWindow::~MainWindow()
{
}

// 链接
void MainWindow::on_pushButton_clicked()
{
	RobotCfg cfg = {};
	cfg.name() = ui.lineEdit->text().trimmed();
	cfg.ip() = ui.lineEdit_2->text().trimmed();
	cfg.brand() = ui.comboBox->currentIndex();
	cfg.cmdPort() = ui.spinBox->value();
	cfg.statePort() = ui.spinBox->value();

	auto rob = component->CreateNewComponent(ComponentType::component_robot);
	if (rob != nullptr) {
		if (rob->Init(cfg.toByteArray()) == 0) {
			m_rob = dynamic_cast<Robot*>(rob);
			return;
		}
		rob->deleteLater();
	}
	QMessageBox::warning(this, "提示", "机械手连接失败");
}
// 停止
void MainWindow::on_pushButton_2_clicked()
{
	while (1);
}
// 暂停
void MainWindow::on_pushButton_3_clicked()
{

}
// 恢复
void MainWindow::on_pushButton_4_clicked()
{

}

